layui.use(['layer','form','table','element','layedit','upload'],function () {
    var layer = layui.layer
        ,form = layui.form
        ,table =layui.table
        ,element = layui.element
        ,layedit = layui.layedit
        ,upload = layui.upload;


    $.ajax({
       url:"/admin/getDriverList"
       ,type:"POST"
        ,success:function (res) {
            var driverList = res.data.drivers;
            $("#owner").empty();
            $.each(driverList,function (i,item) {
                $("#owner").append("<option value='"+item.id+"'>"+item.userName+"</option>");
                form.render();
            });

            var ownerId = $("#ownerId").val();
            $("#owner").val(ownerId);
            form.render();
        }
        ,error:function () {
            layer.msg("系统错误！");
        }
    });





//提交表单
form.on('submit(form)',function (data) {

    var data = {
        "id":$("#id").val(),
        // "busName":$("#busName").val(),
        "idCard":$("#idCard").val(),
        "rentMoney":$("#rentMoney").val(),
        // "owner":$("#owner").val()
    };

    //保存项目
    $.ajax({
        url:"/admin/busUpdate",
        type:"POST",
        data:data,
        success:function (result) {
            // console.log("data=="+form_data)
            if(result.flag){
                layer.confirm(result.message, {
                    btn: ['确定'] //按钮
                }, function(){
                    parent.layui.element.tabDelete('tabs','toBusInfoView');
                });
            }else{
                layer.msg(result.message);
            }
        },
        error:function () {
            layer.msg("系统错误！");
        }
    });

});

});